function flatten(arr) {
    var result = []; // es5
    for (var i = 0, len = arr.length; i < len; i++) {
        if (Array.isArray(arr[i])) { // 后期之秀
            result = result.concat(arr[i])
        } else {
            result.push(arr[i]);
        }
    }
    return result
}

console.log(flatten([1,2,[3],[[4,5],6]]));